#include <atlstr.h>
#include "../../include/shape/Rectangle.h"


void RectangleClass::draw()
{
	LOGFONT f;
	gettextstyle(&f);
	f.lfWeight = 200;
	settextstyle(&f);
	CString s;
	s.Format(_T("%d"), m_data);
	if (getlinecolor() != m_color) setlinecolor(m_color);
	if (m_ifFill) {
		if (getfillcolor() != m_fillColor) setfillcolor(m_fillColor);
		fillrectangle(coord.left, coord.top, coord.right, coord.bottom);
		outtextxy(coord.left, coord.bottom + 10, s);
	}
	else {
		rectangle(coord.left, coord.top, coord.right, coord.bottom);
		outtextxy(coord.left, coord.bottom + 10, s);
	}
}

void RectangleClass::move(Dir dir, int distance)
{
	//LPRECT lpRect = new tagRECT();
	//GetWindowRect(GetHWnd(), lpRect);
	//int length = lpRect->right - lpRect->left;
	//int height = abs(lpRect->bottom - lpRect->top);
	switch (dir)
	{
	case Dir::Left:
		coord.left -= distance;
		coord.right -= distance;
		//if (coord.left <= 0) coord.left = 0;
		break;
	case Dir::Top:
		coord.top -= distance;
		coord.bottom -= distance;
		//if (coord.top <= 0) coord.top = 0;
		break;
	case Dir::Right:
		coord.left += distance;
		coord.right += distance;
		//if (coord.right >= length) coord.right = length;
		break;
	case Dir::Bottom:
		coord.top += distance;
		coord.bottom += distance;
		//if (coord.bottom >= height) coord.bottom = height;
	default:
		break;
	}
}

std::pair<int, int> RectangleClass::getPosition()
{
	return { coord.left, coord.bottom };
}
